-- Leviathan (c) v.v.balashoff
local MouseWheelComponent = require('leviathan/ECS/Input/Components/MouseWheelComponent')
local Class = require('leviathan/Class')

local MouseWheelSystem = Class:derive('InputMouseWheelSystem')

function MouseWheelSystem:new(domain)
    self.name = 'InputMouseWheelSystem'
    self.domain = domain
end

--function MouseWheelSystem:update(dt)
--    local domain = self.domain
--    local input = domain.components['Input']
--    -- clear all async components
--    if input then
--        for _, c in pairs(input) do
--            if c.id == 'ButtonAsyncPressedComponent' then
--            end
--        end
--    end
--end

-- mouse handler functions

function love.wheelmoved(x, y)
    local inp = world:getDomain('Input')
    local e, wc
    e = inp:getEntity('MouseWheel')
    if e then
        wc  = e:getComponent('MouseWheelComponent')
        -- remove old component if there is one
        if wc then
            e:deleteComponent(wc)
        end
        -- add new component
        wc = MouseWheelComponent(x, y)
        e:addComponent(wc)
    end
end

return MouseWheelSystem
